package com.cu.employmentmanagementsystem.common.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * @author CaptainUniverse_
 * @date 2024/2/29
 */
@Getter
public enum ResultCodeEnum
{
    SUCCESS(200,"成功"),
    NOT_LOGIN(401,"未登录"),
    FAIL(500,"失败");

    private Integer code;
    private String desc;

    ResultCodeEnum(Integer code,String desc)
    {
        this.code = code;
        this.desc = desc;
    }

    public static ResultCodeEnum getByCode(Integer code)
    {
        for (ResultCodeEnum resultCodeEnum : ResultCodeEnum.values())
        {
            if(Objects.equals(resultCodeEnum.getCode(), code))
            {
                return resultCodeEnum;
            }
        }
        return null;
    }
}
